﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectEulerSolutions
{
    class Problem3
    {
        public static string Calculate()
        {

            long number = 600851475143;

            long lastPrime = 0;

            for (long i = 2; i <= number; i++)
            {
                if(IsPrime(i))
                    if (number % i == 0)
                    {
                        lastPrime = i;
                        number /= i;
                    }
            }

            return lastPrime.ToString();
        }

        static bool IsPrime(long n)
        {
            for (long i = 2; i < n; i++)
            {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
    }
}
